package com.wm.wmim.server.dbservice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wm.wmim.server.dao.ChatMessageRecordDao;
import com.wm.wmim.server.dbservice.ChatMessageRecordDbService;
import com.wm.wmim.server.dto.bo.req.ListChatMessageRecordReqBO;
import com.wm.wmim.server.entity.ChatMessageRecordDO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 消息记录表(ChatMessageRecord)表服务实现类
 *
 * @author weiming
 * @since 2024-09-02 22:59:15
 */
@Service
public class ChatMessageRecordDbServiceImpl extends ServiceImpl<ChatMessageRecordDao, ChatMessageRecordDO> implements ChatMessageRecordDbService {

    @Override
    public List<ChatMessageRecordDO> listMessageRecord(ListChatMessageRecordReqBO reqBO) {

        LambdaQueryWrapper<ChatMessageRecordDO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ChatMessageRecordDO::getUserId, reqBO.getUserId());
        queryWrapper.eq(ChatMessageRecordDO::getFriendId, reqBO.getFriendUserId());
        queryWrapper.orderByDesc(ChatMessageRecordDO::getSendTime);
        return this.list(queryWrapper);
    }
}

